Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sa: add GetRevokedCertsByShard #7946

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

sa: add GetRevokedCertsByShard #7946

wants to merge 2 commits into from

Conversation

jsha
Copy link
Contributor

@jsha jsha commented Jan 13, 2025

The SA had some logic (not yet in use) to return revoked certificates either by temporal sharding (if req.ShardIdx is zero) or by explicit sharding (if req.ShardIdx is nonzero).

This PR splits the function into two. The existing GetRevokedCerts always does temporal sharding. The new GetRevokedCertsByShard always does explicit sharding. Eventually only GetRevokedCertsByShard will be necessary. This change was discussed in #7094 (comment) and is a precursor to having the crl-updater call both methods, so we can merge the results when generating CRLs.

Which queries for revoked certificates by explicit shard only.

Also, remove explicit shard support from GetRevokedCerts.
@jsha jsha force-pushed the split-getrevokedcerts branch from a087fb6 to 909464d Compare January 14, 2025 23:27
@jsha jsha changed the title sa: split explicit CRL sharding out of GetRevokedCerts sa: add GetRevokedCertsByShard Jan 14, 2025
@jsha jsha marked this pull request as ready for review January 15, 2025 18:08
@jsha jsha requested a review from a team as a code owner January 15, 2025 18:08
@jsha jsha requested a review from beautifulentropy January 15, 2025 18:08
sa/saro.go Outdated Show resolved Hide resolved
@jsha jsha requested review from a team and aarongable and removed request for a team January 17, 2025 23:38
Copy link
Contributor

@aarongable aarongable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except for a mocks improvement.

@@ -271,6 +271,16 @@ func (sa *StorageAuthority) GetRevokedCerts(ctx context.Context, _ *sapb.GetRevo
return &ServerStreamClient[corepb.CRLEntry]{}, nil
}

// GetRevokedCertsByShard is a mock
func (sa *StorageAuthorityReadOnly) GetRevokedCertsByShard(ctx context.Context, _ *sapb.GetRevokedCertsByShardRequest, _ ...grpc.CallOption) (sapb.StorageAuthorityReadOnly_GetRevokedCertsClient, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks to my upstream grpc stream generics work, you shouldn't need to create two different versions of this method that differ only in their receiver and return type! Instead a single mock with this signature from the autogenerated code should work:

Suggested change
func (sa *StorageAuthorityReadOnly) GetRevokedCertsByShard(ctx context.Context, _ *sapb.GetRevokedCertsByShardRequest, _ ...grpc.CallOption) (sapb.StorageAuthorityReadOnly_GetRevokedCertsClient, error) {
func (sa *StorageAuthorityReadOnly) GetRevokedCertsByShard(ctx context.Context, _ *sapb.GetRevokedCertsByShardRequest, _ ...grpc.CallOption) (grpc.ServerStreamingClient[corepb.CRLEntry], error) {

And once you're using that generic return type, both methods can be collapsed into a single method with a StorageAuthorityReadOnly receiver because the mock StorageAuthority embeds the former.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants